import { ecs } from "db://app-game/libs/ecs/ECS";
import { Account } from "../biz/account/Account";
import { LocalStorageManager } from "../biz/storage/LocalStorageManager";
import { GameSaveData } from "../biz/storage/LocalStorageManager.type";
import { Initialize } from "../scene/initialize/Initialize";
import { Level } from "../scene/level/Level";

@ecs.register("SingletonModule")
export class SingletonModuleComp extends ecs.Comp {
  /** 游戏初始化模块 */
  initialize: Initialize = null!;
  /** 游戏账号模块 */
  get account(): Account {
    return this.initialize.account;
  }

  /** 本地存储实例 */
  get storage(): LocalStorageManager {
    return this.initialize.storage;
  }

  /** 本地存储数据 */
  get storageData(): GameSaveData {
    return this.storage.LSM.data;
  }

  /* 关卡模块 */
  level!: Level;

  reset() {}
}

export let smc: SingletonModuleComp = ecs.getSingleton(SingletonModuleComp);
